package edu.hebeu.evil.freshmenguide.Activity;

import android.content.Intent;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jaredrummler.materialspinner.MaterialSpinner;

import edu.hebeu.evil.freshmenguide.R;

/********************************************
 * 工程名：FreshmenGuide
 * 包名：edu.hebeu.evil.freshmenguide.Activity
 * 时间：16-7-7 上午11:28
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class CarActivity extends BaseActivity
{
    private static final String[] item = {"邯郸火车站", "邯郸东站", "邯郸机场", "邯郸汽车总站"};

    private Toolbar toolbar;
    private MaterialSpinner spinner;
    private TextView textView;
    private ScrollView scrollView;
    private ImageView map;
    private CardView tips;
    private TextView tips_title;
    private TextView tips_context;

    private int imgRes = R.drawable.map1;

    @Override
    public int setContentView()
    {
        return R.layout.car_activity;
    }

    @Override
    public String setToolbarTitle()
    {
        return "乘车指南";
    }

    @Override
    public void onCreate()
    {
        initView();
        initData();
        setSpinner();
        onClick();
    }

    /**
     * 初始化控件
     */
    private void initView()
    {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        spinner = (MaterialSpinner) findViewById(R.id.spinner);
        textView = (TextView) findViewById(R.id.textView);
        scrollView = (ScrollView) findViewById(R.id.scrollView);
        map = (ImageView) findViewById(R.id.map);
        tips = (CardView) findViewById(R.id.tips);
        tips_title = (TextView) findViewById(R.id.tips_title);
        tips_context = (TextView) findViewById(R.id.tips_context);
    }

    /**
     * 初始化数据
     */
    private void initData()
    {
        Glide.with(this).load(imgRes).into(map);

        tips_context.setText(R.string.map1_tips);
    }

    /**
     * 设置下拉菜单
     */
    private void setSpinner()
    {
        spinner.setItems(item);
        spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>()
        {
            @Override
            public void onItemSelected(MaterialSpinner view, int position, long id, String item)
            {
                switch (position)
                {
                    case 0:
                        imgRes = R.drawable.map1;
                        Glide.with(CarActivity.this).load(imgRes).into(map);
                        tips_context.setText(R.string.map1_tips);
                        break;
                    case 1:
                        imgRes = R.drawable.map2;
                        Glide.with(CarActivity.this).load(imgRes).into(map);
                        tips_context.setText(R.string.map2_tips);
                        break;
                    case 2:
                        imgRes = R.drawable.map3;
                        Glide.with(CarActivity.this).load(imgRes).into(map);
                        tips_context.setText(R.string.map3_tips);
                        break;
                    case 3:
                        imgRes = R.drawable.map4;
                        Glide.with(CarActivity.this).load(imgRes).into(map);
                        tips_context.setText(R.string.map4_tips);
                        break;

                }
            }
        });
    }

    /**
     * 点击事件
     */
    private void onClick()
    {
        map.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Intent intent = new Intent(CarActivity.this, ImageZoom.class);
                intent.putExtra("IMGRES", imgRes);
                startActivity(intent);
            }
        });
    }


}
